home *** CD-ROM | disk | FTP | other *** search
/ Sound Fx / Sound Fx.iso / Software / UNZIPED / MPW181-5 / _SETUP.1 / header.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-19  |  3.9 KB  |  120 lines

  1. /* header.h
  2.  
  3.     Declarations for MPEG header class
  4.  
  5.     A few layer III, MPEG-2 LSF, and seeking modifications made by Jeff Tsay.
  6.  
  7.    Last modified : 04/19/97 */
  8.  
  9. /*
  10.  *  @(#) header.h 1.7, last edit: 6/15/94 16:55:33
  11.  *  @(#) Copyright (C) 1993, 1994 Tobias Bading (bading@cs.tu-berlin.de)
  12.  *  @(#) Berlin University of Technology
  13.  *
  14.  *  This program is free software; you can redistribute it and/or modify
  15.  *  it under the terms of the GNU General Public License as published by
  16.  *  the Free Software Foundation; either version 2 of the License, or
  17.  *  (at your option) any later version.
  18.  *
  19.  *  This program is distributed in the hope that it will be useful,
  20.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  21.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22.  *  GNU General Public License for more details.
  23.  *
  24.  *  You should have received a copy of the GNU General Public License
  25.  *  along with this program; if not, write to the Free Software
  26.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27.  */
  28.  
  29. #ifndef HEADER_H
  30. #define HEADER_H
  31.  
  32. #include "all.h"
  33. #include "ibitstr.h"
  34. #include "crc.h"
  35.  
  36. enum e_version { MPEG2_LSF, MPEG1 };
  37. enum e_mode { stereo, joint_stereo, dual_channel, single_channel };
  38. enum e_sample_frequency { fourtyfour_point_one, fourtyeight, thirtytwo };
  39.  
  40. // Class for extraction information from a frame header:
  41. class Header
  42. {
  43.  
  44. private:
  45.  
  46.   static const uint32    frequencies[2][4];
  47.   uint32        h_layer, h_protection_bit, h_bitrate_index,
  48.                 h_padding_bit, h_mode_extension;
  49.   e_version h_version;
  50.   e_mode        h_mode;
  51.   e_sample_frequency    h_sample_frequency;
  52.   uint32        h_number_of_subbands, h_intensity_stereo_bound;
  53.   BOOL        h_copyright, h_original;
  54.   BOOL      initial_sync;
  55.   Crc16        *crc;
  56.   uint32    *offset;
  57.   uint16        checksum;
  58.   uint32    framesize;
  59.   uint32    nSlots;
  60.  
  61. public:
  62.  
  63.   Header();
  64.  
  65.   ~Header();
  66.  
  67.   BOOL read_header(Ibitstream *stream, Crc16 **crc);
  68.   // read a 32-bit header from the bitstream
  69.  
  70.   // functions to query header contents:
  71.   e_version version()          { return(h_version); }
  72.   uint32        layer()          { return(h_layer); }
  73.   uint32        bitrate_index()  { return(h_bitrate_index); }
  74.   e_sample_frequency    sample_frequency()   { return(h_sample_frequency); }
  75.   uint32        frequency()      { return frequencies[h_version][h_sample_frequency]; }
  76.  
  77.   e_mode        mode()           { return(h_mode); }
  78.   BOOL        checksums()      { return((BOOL) !h_protection_bit); }
  79.   BOOL        copyright()      { return(h_copyright); }
  80.   BOOL        original()       { return(h_original); }
  81.  
  82.   BOOL        checksum_ok ()   { return ((BOOL) (checksum == crc->checksum ())); }
  83.             // compares computed checksum with stream checksum
  84.  
  85.   // Seeking and layer III stuff
  86.   BOOL      padding()        { return((BOOL) h_padding_bit); }
  87.   uint32    slots()          { return(nSlots); }
  88.   uint32        mode_extension() { return(h_mode_extension); }
  89.   uint32        calculate_framesize(); // made public
  90.  
  91.   // functions which return header informations as strings:
  92.   const char *    layer_string();
  93.   const char *    bitrate_string();
  94.   const char *    sample_frequency_string();
  95.   const char *    mode_string();
  96.   const char * version_string();
  97.  
  98.   uint32        number_of_subbands()     { return(h_number_of_subbands); }
  99.             // returns the number of subbands in the current frame
  100.   uint32        intensity_stereo_bound() { return(h_intensity_stereo_bound); }
  101.             // (Layer II joint stereo only)
  102.             // returns the number of subbands which are in stereo mode,
  103.             // subbands above that limit are in intensity stereo mode
  104.  
  105.   // Scrolling stuff
  106.  
  107. #ifdef SEEK_STOP
  108.   BOOL      stream_seek(Ibitstream *stream, uint32 seek_pos);
  109. #endif // SEEK_STOP
  110.  
  111.   uint32    max_number_of_frames(Ibitstream *stream);
  112.   uint32    min_number_of_frames(Ibitstream *stream);
  113.  
  114.   real      ms_per_frame(); // milliseconds per frame, for time display
  115.   real      total_ms(Ibitstream *stream);
  116.  
  117. };
  118.  
  119. #endif
  120.